/*
 * Task 4. Calendar Seeker
 * Used algoritm from link
 * http://www.base.vingrad.ru/view/3139-Vyichislenie-dnya-nedeli-po-date
 */
import java.text.DateFormatSymbols;
import java.util.*;

/**
 * Program prints out the day of the week
 * for a given day, month and year.
 *
 * @version 2.0 24 Jan 2013
 * @author Yegor Apolonov
 */
public class CalendarSeeker {

    /**
     * Method use class GregorianCalendar
     * @param int[] dateArr is array with year, month, day respectively
     * @return String name of day
     */
    private static String exploreDay(int[] dateArr) {
        
        int year = dateArr[0];
        int month = dateArr[1] - 1; //For numering elements of array
        int day = dateArr[2];
        
        /*Arrays of months for magic expression*/
        int[] magicMonths = {5, 1, 1, 4, 6, 2, 4, 0, 3, 5, 1, 3};
    	
        /*For leap-years restore*/
        if(year % 4 == 0) {
          magicMonths[0] = 1;
          magicMonths[1] = 0;
        }
    	
        /* Convertion number of really months to number of magic months*/
        month = magicMonths[month];
    	    	
        /* Create array with names of days from United Kingdom locale*/
        String[] daysOfWeek = new DateFormatSymbols(Locale.UK).getWeekdays(); 
    	
        int numberOfDay = (year + (int)(year / 4) + month + day) % 7; // Magical calculation
    	
        return  daysOfWeek[numberOfDay - 1];
    	
    }

    /**
     * Method for input
     * @return in array year, month, day
     */
    private static int[] inputDay() {

        int[] dateArr = new int[3];
       
        System.out.println("Enter the number of year:");
        dateArr[0] = new Scanner(System.in).nextInt();

        System.out.println("Enter the number of month 1-12:");
        dateArr[1] = new Scanner(System.in).nextInt();

        System.out.println("Enter the number of day 1-31:");
        dateArr[2] = new Scanner(System.in).nextInt();

        return dateArr;
    }

    public static void main(String args[]) {

        System.out.println(exploreDay(inputDay()));
    }
}
